#include "proto.h"

int main (void)
{
	int tcp_socket;
	struct sockaddr_in server_addr;
	char buf[MSGSIZE] = {};

	tcp_socket = socket (AF_INET, SOCK_STREAM, 0);
	if (-1 == tcp_socket) {
		perror ("socket()");
		exit(1);
	}
	server_addr.sin_family = AF_INET;
	server_addr.sin_port = htons(atoi(SERVER_PROT));
	inet_aton (SERVER_IP, &server_addr.sin_addr);
	if (-1 ==  connect (tcp_socket, (struct sockaddr *)&server_addr, sizeof(server_addr)))
	{
		perror ("connect()");
		goto ERROR;
	}
	
	sleep (5);
	write (tcp_socket, "good morning", 13);
	read (tcp_socket, buf, MSGSIZE);
	puts (buf);

	close (tcp_socket);
	return 0;
ERROR:
	close (tcp_socket);
}
